package com.kazalan.content.document.bl;

import java.util.HashMap;
import java.util.Map;

import com.kazalan.domain.document.Document;
import com.kazalan.domain.document.DocumentAggregate;
import com.kazalan.domain.document.Language;
import com.kazalan.domain.document.Section;

public class DummyDataProvider {

	public static final String FRENCH_TEXT = "(Text francais)";
	public static final String FRENCH_DESCRIPTION = "(Description francaise)";
	public static final String FRENCH_NAME = "(Nom francais)";
	public static final String ENGLISH_TEXT = "(English text)";
	public static final String ENGLISH_DESCRIPTION = "(English description)";
	public static final String ENGLISH_NAME = "(English)";

	private static Language french = new Language("french", "fr");
	private static Language english = new Language("english", "en");
	private static Language creole = new Language("creole", "cr");

	public static DocumentAggregate getDocumentAggregate(String id, String name) {

		DocumentAggregate documentAggregate = new DocumentAggregate();

		Document documentEn = getDocument(id, name, name + ENGLISH_DESCRIPTION,
				name + ENGLISH_TEXT, documentAggregate);

		Document documentFr = new Document();
		documentFr.setId(id + "2");
		documentFr.setName(name + FRENCH_NAME);
		documentFr.setDescription(name + FRENCH_DESCRIPTION);
		documentFr.setText(name + FRENCH_TEXT);
		documentFr.setLanguage(french);
		documentFr.setDocumentAggregate(documentAggregate);

		documentAggregate.setId(id);
		documentAggregate.addDocument(documentEn);
		documentAggregate.addDocument(documentFr);

		return documentAggregate;

	}

	public static Document getDocument(String id, String name,
			String description, String text, DocumentAggregate documentAggregate) {
		Document documentEn = new Document();
		documentEn.setId(id + "1");
		documentEn.setName(name);
		documentEn.setDescription(description);
		documentEn.setText(text);
		documentEn.setLanguage(english);
		documentEn.setDocumentAggregate(documentAggregate);

		Section section1 = getSection("1", "Alphabets", "", 1, documentEn, null);
		Section section11 = getSection("11", "Sub - " + section1.getName(), "",
				1, documentEn, section1);
		Section section12 = getSection("12", "Sub - " + section1.getName(), "",
				2, documentEn, section1);
		Section section13 = getSection("13", "Sub - " + section1.getName(), "",
				3, documentEn, section1);
		section1.addSection(section11);
		section1.addSection(section12);
		section1.addSection(section13);

		Section section2 = getSection("2", "Numbers", "", 2, documentEn, null);
		Section section21 = getSection("21", "Sub - " + section2.getName(), "",
				1, documentEn, section2);
		Section section22 = getSection("22", "Sub - " + section2.getName(), "",
				2, documentEn, section2);
		Section section23 = getSection("23", "Sub - " + section2.getName(), "",
				3, documentEn, section2);
		section2.addSection(section21);
		section2.addSection(section22);
		section2.addSection(section23);

		Section section3 = getSection("3", "Days and Month", "", 3, documentEn,
				null);
		Section section4 = getSection("4", "Present tences", "", 4, documentEn,
				null);
		Section section5 = getSection("4", "Past tences", "", 5, documentEn,
				null);

		documentEn.addSection(section1);
		documentEn.addSection(section2);
		documentEn.addSection(section3);
		documentEn.addSection(section4);
		documentEn.addSection(section5);
		return documentEn;
	}

	public static Section getSection(String id, String name, String number,
			Integer order, Document document, Section parent) {

		Section section = new Section();
		section.setId(id);
		section.setName(name);
		section.setOrder(1);
		section.setDocument(document);
		section.setSectionNumber(number);

		if (parent != null) {
			section.setParent(parent);
		}

		return section;
	}

	public static Map<String, Language> getLanguages() {

		Map<String, Language> languages = new HashMap<String, Language>();

		languages.put(french.getCode(), french);
		languages.put(english.getCode(), english);
		languages.put(creole.getCode(), creole);

		return languages;

	}

}
